home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / flip / flip.frm < prev    next >
Text File  |  1995-12-05  |  9KB  |  273 lines

  1. VERSION 2.00
  2. Begin Form Flip 
  3.    BackColor       =   &H00FF0000&
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Flip"
  6.    ClientHeight    =   4950
  7.    ClientLeft      =   1185
  8.    ClientTop       =   1500
  9.    ClientWidth     =   4950
  10.    FontBold        =   -1  'True
  11.    FontItalic      =   0   'False
  12.    FontName        =   "System"
  13.    FontSize        =   9.75
  14.    FontStrikethru  =   0   'False
  15.    FontUnderline   =   0   'False
  16.    Height          =   5355
  17.    Icon            =   FLIP.FRX:0000
  18.    Left            =   1125
  19.    LinkMode        =   1  'Source
  20.    LinkTopic       =   "Form1"
  21.    MaxButton       =   0   'False
  22.    MinButton       =   0   'False
  23.    ScaleHeight     =   330
  24.    ScaleMode       =   3  'Pixel
  25.    ScaleWidth      =   330
  26.    Top             =   1155
  27.    Width           =   5070
  28.    Begin PictureBox Picture1 
  29.       AutoRedraw      =   -1  'True
  30.       AutoSize        =   -1  'True
  31.       BorderStyle     =   0  'None
  32.       FontBold        =   -1  'True
  33.       FontItalic      =   0   'False
  34.       FontName        =   "System"
  35.       FontSize        =   9.75
  36.       FontStrikethru  =   0   'False
  37.       FontUnderline   =   0   'False
  38.       Height          =   990
  39.       Left            =   270
  40.       Picture         =   FLIP.FRX:0302
  41.       ScaleHeight     =   66
  42.       ScaleMode       =   0  'User
  43.       ScaleWidth      =   66
  44.       TabIndex        =   0
  45.       Top             =   840
  46.       Visible         =   0   'False
  47.       Width           =   990
  48.    End
  49.    Begin PictureBox Picture3 
  50.       AutoRedraw      =   -1  'True
  51.       AutoSize        =   -1  'True
  52.       BorderStyle     =   0  'None
  53.       FontBold        =   -1  'True
  54.       FontItalic      =   0   'False
  55.       FontName        =   "System"
  56.       FontSize        =   9.75
  57.       FontStrikethru  =   0   'False
  58.       FontUnderline   =   0   'False
  59.       Height          =   990
  60.       Left            =   1290
  61.       Picture         =   FLIP.FRX:0CC4
  62.       ScaleHeight     =   66
  63.       ScaleMode       =   0  'User
  64.       ScaleWidth      =   66
  65.       TabIndex        =   2
  66.       Top             =   840
  67.       Visible         =   0   'False
  68.       Width           =   990
  69.    End
  70.    Begin PictureBox Picture5 
  71.       AutoRedraw      =   -1  'True
  72.       AutoSize        =   -1  'True
  73.       BorderStyle     =   0  'None
  74.       FontBold        =   -1  'True
  75.       FontItalic      =   0   'False
  76.       FontName        =   "System"
  77.       FontSize        =   9.75
  78.       FontStrikethru  =   0   'False
  79.       FontUnderline   =   0   'False
  80.       Height          =   990
  81.       Left            =   2340
  82.       Picture         =   FLIP.FRX:1686
  83.       ScaleHeight     =   66
  84.       ScaleMode       =   0  'User
  85.       ScaleWidth      =   66
  86.       TabIndex        =   4
  87.       Top             =   840
  88.       Visible         =   0   'False
  89.       Width           =   990
  90.    End
  91.    Begin PictureBox Picture2 
  92.       AutoRedraw      =   -1  'True
  93.       BorderStyle     =   0  'None
  94.       FontBold        =   -1  'True
  95.       FontItalic      =   0   'False
  96.       FontName        =   "System"
  97.       FontSize        =   9.75
  98.       FontStrikethru  =   0   'False
  99.       FontUnderline   =   0   'False
  100.       Height          =   990
  101.       Left            =   3480
  102.       ScaleHeight     =   66
  103.       ScaleMode       =   0  'User
  104.       ScaleWidth      =   66
  105.       TabIndex        =   1
  106.       Top             =   840
  107.       Visible         =   0   'False
  108.       Width           =   990
  109.    End
  110.    Begin PictureBox Picture4 
  111.       AutoRedraw      =   -1  'True
  112.       BorderStyle     =   0  'None
  113.       FontBold        =   -1  'True
  114.       FontItalic      =   0   'False
  115.       FontName        =   "System"
  116.       FontSize        =   9.75
  117.       FontStrikethru  =   0   'False
  118.       FontUnderline   =   0   'False
  119.       Height          =   480
  120.       Left            =   0
  121.       Picture         =   FLIP.FRX:2048
  122.       ScaleHeight     =   32
  123.       ScaleMode       =   0  'User
  124.       ScaleWidth      =   800
  125.       TabIndex        =   3
  126.       Top             =   3120
  127.       Visible         =   0   'False
  128.       Width           =   12000
  129.    End
  130. End
  131.  
  132. Declare Function BitBlt% Lib "gdi" (ByVal destDC%, ByVal x%, ByVal Y%, ByVal w%, ByVal H%, ByVal srcDC%, ByVal xSrc%, ByVal ySrc%, ByVal Rop&)
  133. Declare Function StretchBlt% Lib "gdi" (ByVal destDC%, ByVal x%, ByVal Y%, ByVal w%, ByVal H%, ByVal srcDC%, ByVal xSrc%, ByVal ySrc%, ByVal wSrc%, ByVal hSrc%, ByVal Rop&)
  134.  
  135. Const SRCCOPY = &HCC0020
  136.  
  137. Dim cxBorders%, cyBorders%, Flipped%(63)
  138.  
  139. Sub Form_Load ()
  140.    x% = MsgBox("- Left button flips cells" + Chr$(13) + "- Right button X's out Cells", 0, "Mouse buttons")
  141.    Picture2.BackColor = Flip.BackColor
  142.    Picture2.Height = Picture1.Height
  143.    Picture2.Width = Picture1.Width
  144. End Sub
  145.  
  146. Sub Form_MouseUp (Button As Integer, Shift As Integer, x As Single, Y As Single)
  147.  
  148. '* Determine what Cell was clicked and what Icon should
  149. '* be displayed when flipped.
  150.  
  151.   IX% = x \ Picture1.Width
  152.   IY% = Y \ Picture1.Height
  153.   IconNum% = IX% + (IY% * 5)
  154.  
  155. '* Determine upper left hand corner of Cell within form
  156.  
  157.   IX% = IX% * Picture1.Width
  158.   IY% = IY% * Picture1.Height
  159.  
  160. '* Copy Icon from IconsBitmap to middle of "Working"
  161. '* Picture control in preparation for flipping.
  162. '* If displaying the Icon, The icon is inverted horizontally
  163. '* before flipping so when it is flipped, it appears normally
  164.  
  165.   If Button = 1 Then
  166.     If Flipped%(IconNum%) Then
  167.       Z% = BitBlt(Picture3.hDC, 18, 18, 32, 32, Picture4.hDC, IconNum% * 32, 0, SRCCOPY)
  168.     Else
  169.       Z% = StretchBlt(Picture3.hDC, 49, 18, -32, 32, Picture4.hDC, IconNum% * 32, 0, 32, 32, SRCCOPY)
  170.     End If
  171.  
  172.     FlipWidth% = Picture1.Width
  173.  
  174.   '* Flip the Cell
  175.  
  176.     For I% = 0 To Picture1.Width Step 10
  177.     
  178.       Picture2.Cls
  179.  
  180.       If Flipped%(IconNum%) Then
  181.     
  182.       '* Flip cell horizontally
  183.     
  184.         If ((Not Flipped%(IconNum%)) And (I% < Picture1.Width \ 2)) Or (Flipped%(IconNum%) And (I% >= Picture1.Width \ 2)) Then
  185.           Z% = StretchBlt(Picture2.hDC, 0, I%, Picture1.Height, FlipWidth%, Picture1.hDC, 0, 0, CInt(Picture1.Width), CInt(Picture1.Height), SRCCOPY)
  186.         Else
  187.           Z% = StretchBlt(Picture2.hDC, 0, I%, Picture1.Height, FlipWidth%, Picture3.hDC, 0, 0, CInt(Picture1.Width), CInt(Picture1.Height), SRCCOPY)
  188.         End If
  189.   
  190.       Else
  191.   
  192.       '* Flip cell Vertically
  193.   
  194.         If ((Not Flipped%(IconNum%)) And (I% < Picture1.Width \ 2)) Or (Flipped%(IconNum%) And (I% >= Picture1.Width \ 2)) Then
  195.           Z% = StretchBlt(Picture2.hDC, I%, 0, FlipWidth%, Picture1.Height, Picture1.hDC, 0, 0, CInt(Picture1.Width), CInt(Picture1.Height), SRCCOPY)
  196.         Else
  197.           Z% = StretchBlt(Picture2.hDC, I%, 0, FlipWidth%, Picture1.Height, Picture3.hDC, 0, 0, CInt(Picture1.Width), CInt(Picture1.Height), SRCCOPY)
  198.         End If
  199.   
  200.       End If
  201.   
  202.     '* Display partially flipped Cell on Form
  203.   
  204.       Z% = BitBlt(hDC, IX%, IY%, Picture1.Width, Picture1.Height, Picture2.hDC, 0, 0, SRCCOPY)
  205.       FlipWidth% = FlipWidth% - 20
  206.     Next
  207.     
  208.     Flipped%(IconNum%) = Not Flipped%(IconNum%)
  209.   
  210.    '* Display final cell on Form, either Icon cell or
  211.    '* or normal unflipped cell background
  212.  
  213.     If Flipped%(IconNum%) Then
  214.       Z% = BitBlt(Picture3.hDC, 18, 18, 32, 32, Picture4.hDC, IconNum% * 32, 0, SRCCOPY)
  215.       Z% = BitBlt(hDC, IX%, IY%, Picture1.Width, Picture1.Height, Picture3.hDC, 0, 0, SRCCOPY)
  216.     Else
  217.       Z% = BitBlt(hDC, IX%, IY%, Picture1.Width, Picture1.Height, Picture1.hDC, 0, 0, SRCCOPY)
  218.     End If
  219.  
  220.   ElseIf Button = 2 Then
  221.  
  222. '* X out cell
  223.  
  224.     XWidth% = 2
  225.     For I% = (Picture1.Width \ 2) - 2 To 0 Step -4
  226.       Z% = StretchBlt(hDC, IX% + I%, IY% + I%, XWidth%, XWidth%, Picture5.hDC, 0, 0, CInt(Picture1.Width - 2), CInt(Picture1.Height - 2), SRCCOPY)
  227.       XWidth% = XWidth% + 8
  228.     Next
  229.     Z% = BitBlt(hDC, IX%, IY%, Picture1.Width, Picture1.Height, Picture5.hDC, 0, 0, SRCCOPY)
  230.     
  231.   End If
  232. End Sub
  233.  
  234. Sub Form_Paint ()
  235.  
  236. '* Repaint form row by row, copying normal backgroup
  237. '* cell bitmap to form if cell is not flipped, or the
  238.